import java.util.concurrent.atomic.AtomicInteger;

public class Demo_AtomicInteger {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger();
        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 5000; i++){
                atomicInteger.getAndIncrement();
            }
        });
        Thread t2 = new Thread(() -> {
            for(int i = 0; i < 5000; i++){
                atomicInteger.getAndIncrement();
            }
        });
        Thread t3 = new Thread(() -> {
            for(int i = 0; i < 5000; i++){
                atomicInteger.getAndIncrement();
            }
        });
        t1.start();
        t2.start();
        t3.start();
        t1.join();
        t2.join();
        t3.join();
        System.out.println("atomicInteger = " + atomicInteger);
    }
}